package cn.whale.tools;

import cn.hutool.http.HttpUtil;
import dev.langchain4j.agent.tool.P;
import dev.langchain4j.agent.tool.Tool;
import lombok.extern.slf4j.Slf4j;

import java.util.HashMap;

@Slf4j
public class WeatherTool {

    @Tool(value="计算两个数之和")
    public int add(int a , int b) {
        return a + b;
    }

 
    HashMap<String,Integer> code = new HashMap<>(){{
        put("成都",510100);
    }};

    @Tool("查询该城市的天气")
    public String weather(@P("城市") String city) {
        String url = "https://api.map.baidu.com/weather/v1/?district_id="+code.get(city)+"&data_type=all&ak=dRXpbZlQSEtuWKqvV4jx2XgeimzlDBsx";
        log.info("查询天气url = {}",url);
        return HttpUtil.get(url);
    }
}

